<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" href="../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../css/iconfont.css">
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery.min-1.11.1.js"></script>
		<script src="../js/mui.picker.min.js"></script>
		<style>
			span{float:left; padding:0 5px;}
			.bottom{ width: 70%; margin-left: 15%; line-height:30px; background-color: #0284B8; color:#FFFFFF;}
			.mui-table-view .mui-media-object{height:58px; width:58px;}
			.bottom{margin-top:10px;}
			.mui-table-view{font-size: 14px;}
			/*列表样式*/
			.pat_class{ float:left;}
			.pat_class img{ float: left; width: 25%;}
			.mui-media-body{ float: left; width: 70%; margin-left:5%;}
			.mui-media-body-l{ float: left; width: 100%;}
			.mui-media-body-l span{ float: left; margin-right: 10px; white-space: pre-wrap;}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">随访患者</h1>
		</header>
		<div class="mui-conten mui-query-admin" style="margin-top:45px;">
			<div style="font-size: 12px; clear: both; line-height:30px; margin-left:20px;">近期需要进行随访的患者</div>
			<ul class="mui-table-view" id="follow_qy_ul">
			
			</ul>
		</div>
		<script src="../js/mui.js"></script>
		<script src="../js/request.js"></script>
		<script type="text/javascript">
			mui.init();
			var rows ="";
			var listname = "";
			//获取变量
			var self = localStorage.getItem("name")
			var data = JSON.parse(self)
			//方法
			//$("#follow_qy_ul").html("");
			var listcont ="";
			//console.log(data["obj"],data["obj"].hospId,data["obj"].regionId)
			$.ajax(getRequestUrl.url+'/mobile/ChronicWarning/getChronicWarning ',{
				data:{
					hosp_id:data["obj"].hospId,
					region_id:data["obj"].regionId,
					warning_day:700
				},
				dataType:'json',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				success:function(data){
					console.log(data["rows"])
					rows = data["rows"]
				console.log(JSON.stringify(rows[1]))
					if(data.status==1){
						for(var i=0; i<data["rows"].length; i++){
									var date0 = new Date(data["rows"][i].birthday)
									var date1 = new Date();
									var year0 = date0.getFullYear();
									var year1 = date1.getFullYear();
									var age = year1 - year0;
									var vistdata = new Date(data["rows"][i].visitDate)
									var visi = vistdata.getFullYear()+'-'+ (vistdata.getMonth()+1) +'-'+vistdata.getDate();
									var arry = ['门诊','家庭','电话']
									//var arry_way = arry[data["rows"][i].visitWay];
									//listname = data["rows"][i].chronic_name2;
									listcont += '<li class="mui-table-view-cell mui-media">'
									+'<a class="pat_class" onclick="openurl('+i+')">'
									+'<img id="Pat_img'+i+'" class="mui-pull-left" src="../images/Patient-m.png">'
									+'<div class="mui-media-body">'
									+'<div class="mui-media-body-l"><span>'+data["rows"][i].name+'</span><span>性别:'+data["rows"][i].sex+'</span><span>年龄:'+age+'</span></div>'
									+'<div class="mui-media-body-l"><span class="mui-ellipsis">随访到期日:'+data["rows"][i].next_time+'</span></div>'
									+'<div class="mui-media-body-l"><span class="mui-ellipsis">电话:</span>'+data["rows"][i].telephone+'</div>'
									+'<div class="mui-media-body-l"><span class="mui-ellipsis">地址:'+data["rows"][i].home_address+'</span></div>'
									+'</div>'
									+'</a>'
									+'</li>';	
						}
					}else{
						alert(data.message);
					}
					$("#follow_qy_ul").append(listcont)
					for(var j=0; j<data["rows"].length; j++){
						console.log(j)
						//头像性别
						if(data["rows"][j].sex == "女"){
							$("#Pat_img"+j).attr("src", "../images/Patient-w.png");
						}else{
							$("#Pat_img"+j).attr("src", "../images/Patient-m.png");
						}
					}
				},
				error:function(xhr,type,errorThrown){
					
				}
			});	
			//跳转
			function openurl(i){
				var listdata = rows[i];
				listdata["ehrId"] = listdata.ehr_id;
				listdata["nhCode"] = listdata.nh_code;
				listdata["ehrCode"] = listdata.ehr_code;
				listdata["idCard"] = listdata.id_card;
				listdata["homeAddress"] = listdata.home_address;
				var listname = rows[i].chronic_name2;
				if(rows[i].chronic_name == 1){
					alert("当前为高危人群")
				}else{
					console.log(listname,listdata)
					mui.openWindow({
						url: 'follow_up.html', 
						id:'follow_up',
						extras:{
							name:listname,
							data:JSON.stringify(listdata)
						}
					});
				}
			}
		</script>
	</body>
</html>
